package cn.iocoder.yudao.module.pay.enums.notify;

import cn.hutool.core.util.ArrayUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 支付通知类型
 *
 * @author 芋道源码
 */
@Getter
@AllArgsConstructor
public enum PayNotifyTypeEnum {

    ORDER(1, "支付单"),
    ORDER_DEPOSIT(10, "定金支付单"),
    ORDER_DELAY(11, "延期费支付单"),
    ORDER_PROCESS(12, "工费支付单"),
    ORDER_ADDITIONAL(13, "附加费支付单"),
    ORDER_DEDUCT(14, "扣项费用"),

    SETTLE_ORDER(20, "结算单"),
    SETTLE_BOOM(21, "关闭订单结算"),
    SETTLE_NO_METAL(22, "自助结算"),

    REFUND(30, "退款单"),
    TRANSFER(60, "转账单")
    ;

    public static PayNotifyTypeEnum getEnum(Integer type) {
        if (type == null) {
            return null;
        }
        return ArrayUtil.firstMatch(item -> item.getType().equals(type), values());
    }

    /**
     * 类型
     */
    private final Integer type;
    /**
     * 名字
     */
    private final String name;

    public static boolean isSettle(Integer payType) {
        return SETTLE_ORDER.getType().equals(payType)
                || SETTLE_BOOM.getType().equals(payType)
                || SETTLE_NO_METAL.getType().equals(payType);
    }
}
